angular.module('music_type', [])
    .controller('music_typeCtrl', function ($rootScope, $scope, httpUtil) {
        $scope.typeList = [];
        $scope.currentType = '';
        $scope.songList = [];

        //初始化页面
        init();
        function init (){
            httpUtil.httpSend('Music_musicType.action', null, function(data){
                $scope.typeList = data.data;
            });
            changeType({id: '', name: ''});
        }

        //切换类型
        $scope.changeTypeFun = changeType;
        function changeType(type) {
            $scope.currentType = type.name;
            var params = {
                type: type.id,
                firstIndex: 0,
                maxSums: 12
            };
            httpUtil.httpSend('Music_musicList.action', params, function(data){
                $scope.songList = data.data;
            });
        }
    });